<?php
require_once ("../../config/config.php");
require_once ("../../config/constants.php");
require_once ("../../db/queries.php");
require_once ("../../common/common.php");

function getMOTD($username) {
	if(strcmp ($username,"")==0){
		$randomNumber = 1;//TODO: get random number
		$strQuery = "select * from motd where id="+ $randomNumber;	
	}else{
		$strQuery = "select motd_id from user where username='" . $username ."'";
		$result = mysql_query($strQuery);
		$row = mysql_fetch_array($result);
		$motdId= $row[0];		
		$strQuery = "select * from motd where id=". $motdId;
	}
	return generateResultSet($strQuery);
}

makeXML(getMOTD($username));
?>